package so.sao.code.service.domain;

import java.util.HashMap;
import java.util.Map;

import so.sao.top.core.util.enums.NamedEnumEntity;

/**
 * 码类型枚举类
 * 
 * @author
 *
 */
//TODO 迁移到
public enum CodeType implements NamedEnumEntity<Integer> {

	PACKAGE1(1, "箱码1-6"), PACKAGE2(2, "箱码2-6"),PACKAGE3(3, "箱码2-6-6"), ROLL(10, "ROLL"), SINGLE(20, "SINGLE"),MAPPING(30, "mapping");

	private Integer id; // ID

	private String name; // 名称

	private CodeType(Integer id, String name) {
		this.id = id;
		this.name = name;
	}

	@Override
	public Integer getValue() {
		return id;
	}

	public String getName() {
		return name;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * mapping
	 */
	public static Map<Integer, CodeType> codeTypeMapping = new HashMap<>();

	static {
		for (CodeType codeType : CodeType.values()) {
			codeTypeMapping.put(codeType.getId(), codeType);
		}
	}

	/**
	 * 
	 * @param id
	 * @return
	 */
	public static CodeType get(Integer id) {
		return codeTypeMapping.get(id);
	}

	/**
	 * 多少个逗号。
	 * @param codeType
	 * @return
	 */
	public static Integer getCommaPerLine(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 7;
		case PACKAGE2:
			return 7;
		case PACKAGE3:
			return 7;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}

	/**
	 * 多少瓶码
	 * @param codeType
	 * @return
	 */
	public static Integer getCapCount(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 6;
		case PACKAGE2:
			return 6;
		case PACKAGE3:
			return 12;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}
	
	/**
	 * 多少瓶码
	 * @param codeType
	 * @return
	 */
	public static Integer getCapCountForMapping(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 6;
		case PACKAGE2:
			return 6;
		case PACKAGE3:
			return 6;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}
	

	/**
	 * 多少箱码
	 * @param codeType
	 * @return
	 */
	public static Integer getPackageCount(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 1;
		case PACKAGE2:
			return 2;
		case PACKAGE3:
			return 2;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}
	
	/**
	 * 多少箱码
	 * @param codeType
	 * @return
	 */
	public static Integer getPackageCountForMapping(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 1;
		case PACKAGE2:
			return 1;
		case PACKAGE3:
			return 1;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}
	
	/**
	 * 多少个“|”
	 * @param codeType
	 * @return
	 */
	public static Integer getPipePerLine(CodeType codeType) {
		switch (codeType) {
		case PACKAGE1:
			return 1;
		case PACKAGE2:
			return 2;
		case PACKAGE3:
			return 8;
		default:
			throw new IllegalArgumentException("Value [" + codeType + "] not support!");
		}
	}
	

}
